<?php
     if(isset($_POST["submit"]) && $_POST["submit"] == "Login")  

    {
        $user = $_POST["username"];  
        $psw = $_POST["password"];  
        if($user == "" || $psw == "")  
        { 
            echo "<script>alert('请输入用户名或密码！'); history.go(-1);</script>";  
        }  
        else 
        {  

            $conn=mysqli_connect("localhost","root","","cqeec",3306);
            mysqli_set_charset($conn,"utf8"); 

            $sql = "select username,password from user where username = '$_POST[username]' and password = '$_POST[password]'";  
            $result = mysqli_query($conn,$sql);            
            if ($result)  
            {  
                // $row = mysqli_fetch_array($result);  //将数据以索引方式储存在数组中  
                echo $row; 
                echo "<script> alert('登陆成功！');parent.location.href='loding.html'; </script>";
                // echo "<script>alert('提交成功！');</script>";  
                // header ("location:loding.html");
            }  
            else 
            {  

                echo "<script>alert('用户名或密码不正确！');history.go(-1);</script>";  
            }  
        }  
    }
     else 
     {  
          echo "<script>alert('提交未成功！'); history.go(-1);</script>";  
     }  
?>